import React, { useMemo } from 'react'

export default function Details_num(props) {
    let { goodsid,state } = props
    // 计算数量
    let num = useMemo(() => {
        let sum = 0
        goodsid.forEach(item => {
            sum += item.count
        });
        return sum
    }, [goodsid])
    // 计算价格
    let prices = useMemo(() => {
        let sum = 0
        goodsid.forEach(item => {
            sum += item.count * item.price
        });
        return sum
    }, [goodsid])
    return (
        <div className='details_num'>
            <div className="details_num_list">
                <p className='details_num_list_p'>
                    订单总价
                    <span style={{fontSize:"0.26rem",marginLeft:"0.1rem",color:"#ccc"}}>共{num}件商品</span>
                </p>
                <p style={{fontSize:"0.36rem",color:"#99b97d",fontWeight:700}}>
                    ￥{prices}
                </p>
            </div>
            <div className="details_num_list" style={{display:state==1?"block":"none"}}>
                <p className='details_num_list_p'>优惠卷</p>
                <p>
                    <span>更多</span>
                </p>
            </div>
        </div>
    )
}
